package com.dunqi.gpm.cangxi.home.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.dunqi.gpm.cangxi.R;
import com.dunqi.gpm.cangxi.common.base.RecyclerAdapter;
import com.dunqi.gpm.cangxi.common.util.CommonUtil;
import com.dunqi.gpm.cangxi.common.util.SpannableStringUtils;
import com.dunqi.gpm.cangxi.home.bean.EarlyInfo;
import com.dunqi.gpm.cangxi.home.fragment.HomeFragment;

import java.util.List;

/**
 * Created by Administrator on 2017/11/26.
 */
public class ApprovalReviewAdapter extends RecyclerAdapter<EarlyInfo> {

    private final String[] stageStatuss;
    private int[] resIds;

    public ApprovalReviewAdapter(@Nullable List<EarlyInfo> data) {
        super(R.layout.item_approval_review, data);
        //    0 创建
//1 提交审批申请(实际启动)
//2 完成审批(实际完成)
        resIds = new int[]{R.mipmap.yub,R.mipmap.yub, R.mipmap.yuy, R.mipmap.yur};
        //1:蓝灯 2:黄灯  3:红灯
        stageStatuss = new String[]{"待申请", "待完成", "已完成"};
    }

    @Override
    protected void convert(BaseViewHolder helper, EarlyInfo item) {
        TextView project_name_tv = helper.getView(R.id.project_name_tv);
        project_name_tv.setText(item.getProjectName());

        int light = item.getLight();
        ImageView light_iv = helper.getView(R.id.light_iv);
        if (light == 0) {
            light_iv.setVisibility(View.GONE);
        } else {
         //   light_iv.setVisibility(View.VISIBLE);
            light_iv.setImageResource(resIds[light]);
        }

        TextView state_name_tv = helper.getView(R.id.state_name_tv);
        state_name_tv.setText("阶段名称:" + item.getStageName());

        int stageStatus = item.getStageStatus();

        TextView audit_status_tv = helper.getView(R.id.audit_status_tv);

        int color;
        if (stageStatus == 1) {
            color = CommonUtil.getColor(R.color.material_deep_orange_400);
        } else {
            color = CommonUtil.getColor(R.color.action_text_color_enabled);
        }

        audit_status_tv.setText(SpannableStringUtils.getBuilder("状态:")
                .append(stageStatuss[stageStatus])
                .setForegroundColor(color)
                .create());


        TextView commitTv = helper.getView(R.id.commit_tv);
        int type = HomeFragment.homeMenuId;


        String text = "";
        commitTv.setVisibility(View.VISIBLE);
        commitTv.setText(text);

    }

}
